Skip to content

Conversation

@cpatino-intive
Copy link
Contributor

recovery consolidate from wallet address
TASKS: WP-5143

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for recovering consolidation sweeps from TRX and Solana wallet addresses via a new /recoveryConsolidations endpoint.

  • Extend coinUtils to recognize Sol and TRX coins.
  • Define a new API spec, router entry, handler, and client interfaces for the recovery consolidations endpoint.
  • Add end‐to‐end tests covering TRX and Solana consolidation recovery flows.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/shared/coinUtils.ts Added isSolCoin and isTrxCoin helpers.
src/api/master/routers/masterApiSpec.ts Declared new request/response types and route spec.
src/api/master/handlers/recoveryConsolidationsWallet.ts Implemented handler logic for TRX/Sol consolidation recovery.
src/api/master/clients/enclavedExpressClient.ts Extended RecoveryMultisigOptions to accept MPC transaction types.
src/tests/api/master/recoveryConsolidationsWallet.test.ts Added tests for TRX and Solana consolidation recovery.
Comments suppressed due to low confidence (1)

src/api/master/routers/masterApiSpec.ts:189

  • Using t.any for the signed transactions response is too permissive. Consider defining a more specific transaction schema to improve validation and client typing.
    signedTxs: t.array(t.any), // Array of fully signed transactions

);

// 1. Build unsigned consolidations
if (isSolCoin(sdkCoin)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for having these if conditions. If the recoverConsolidations method is implemented for a coin, we should continue. If not, then we should throw an error saying it is not supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

txs = result.transactions;
}

console.log(txs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logger.debug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +50 to +118
const signedTxs = [];
try {
for (const tx of txs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are there multiple unsigned sweeps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return result from sdkCoin.recoverConsolidations is transaction array.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess they are all txs from receive address -> base.

userKey: userPub,
backupKey: backupPub,
bitgoKey,
durableNonces: req.decoded.durableNonces!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this; just do an if check to throw an error if coin is sol and req.decoded.durableNonces is undefined. But call sdkCoin.recoverConsolidations( only once

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@cpatino-intive cpatino-intive force-pushed the WP-5143/recovery-consolidate branch from f679941 to 8aff26f Compare July 3, 2025 19:01
@cpatino-intive cpatino-intive changed the base branch from master to WP-4736/utxo-recoveries July 3, 2025 19:17
@cpatino-intive cpatino-intive changed the base branch from WP-4736/utxo-recoveries to WP-4793/utxo-accelerate July 3, 2025 19:18
pranavjain97
pranavjain97 previously approved these changes Jul 4, 2025
Base automatically changed from WP-4793/utxo-accelerate to master July 7, 2025 11:30
@cpatino-intive cpatino-intive dismissed pranavjain97’s stale review July 7, 2025 11:30

The base branch was changed.

Comment on lines +50 to +118
const signedTxs = [];
try {
for (const tx of txs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess they are all txs from receive address -> base.

Comment on lines 29 to 102
const result = await (sdkCoin as any).recoverConsolidations({
...req.decoded,
userKey: userPub,
backupKey: backupPub,
bitgoKey,
durableNonces: req.decoded.durableNonces,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't cast to any, use the appropriate coin classes that support recoverConsolidations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 24 to 91
if (typeof (sdkCoin as any).recoverConsolidations !== 'function') {
throw new Error(`recoverConsolidations is not supported for coin: ${coin}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. create a type guard instead that validates sdkCoin supports recoverConsolidations and returns an extended BaseCoin type.

Comment on lines 202 to 217
durableNonces: t.union([
t.undefined,
t.type({
publicKeys: t.array(t.string),
secretKey: t.string,
}),
]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can use optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 197 to 200
startingScanIndex: t.union([t.undefined, t.number]), // Optional
endingScanIndex: t.union([t.undefined, t.number]), // Optional
seed: t.union([t.undefined, t.string]), // Optional (Sol)
tokenContractAddress: t.union([t.undefined, t.string]), // Optional (TRX/Sol)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just use optional(t.x)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 194 to 196
userPub: t.string,
backupPub: t.string,
bitgoKey: t.string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need all 3 values, the pub for them all is going to be the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@cpatino-intive cpatino-intive force-pushed the WP-5143/recovery-consolidate branch 3 times, most recently from acaef72 to 5675ff4 Compare July 11, 2025 17:47
@cpatino-intive cpatino-intive changed the base branch from master to WP-5166-eddsa-recovery-v2 July 11, 2025 17:47
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo force-pushed the WP-5166-eddsa-recovery-v2 branch 3 times, most recently from ff6ecf8 to 88eac6b Compare July 11, 2025 20:05
@cpatino-intive cpatino-intive force-pushed the WP-5143/recovery-consolidate branch from 5675ff4 to 41f7b16 Compare July 14, 2025 13:36
Base automatically changed from WP-5166-eddsa-recovery-v2 to master July 14, 2025 22:14
@cpatino-intive cpatino-intive force-pushed the WP-5143/recovery-consolidate branch from 75b87bc to 57775b3 Compare July 15, 2025 23:49
bitgoKey: bitgoPub,
});

console.log(`Recovery consolidations result: ${JSON.stringify(result)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think we need this.

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo merged commit 0e5ab4f into master Jul 16, 2025
3 checks passed
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo deleted the WP-5143/recovery-consolidate branch July 16, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants